Email and Web Site Addresses

by Gordon Sweet

Home

Tip Corner: Using

Game Programming

Round Buttons

Rotating Objects

LBW: Book Marks

Slide Puzzle

Speech DLL

Addresses

Beginners Programming

Newsletter help

Index


Some while ago it was explained how to adapt a ShellExecute routine to activate say Internet Explorer and Outlook Express to access a Web Site Address for Email address. I adapted this clever routine with my ' pet ' coloured menu system as below. I find the advantages of this method is that it is not only quicker than the methods provided by Windows, but that all you favourite addresses of either type can be displayed and activated on one list. The list is far easier to amend and backup, than searching where Windows hides them under Email and Web site Favorite addresses. Also it gives far greater protection against the popular viruses that use the addresses in say Outlook Express to propagate to others. In fact there is no longer any need to store any addresses in Outlook Express, apart from perhaps your own for testing and monitoring, in case you ever catch such a virus. You can change the name of the opening LB1.TXT file further to prevent hacking.

There is a limit of 95 to the entries, but a Right Click activates the filedialog in [nfile] to open any other file. Note the first two lines of any file must be as follows to allow Notepad to access the file for additions and amendments, but resorting of the file entries will occur subsequently.

* AMEND LIST *
DO NOT ALTER THESE 2 LINES OR ALLOW OTHERS ABOVE THEM

Data from the file is loaded at [start] before a Window is created to determine the height for WindowHeight and the 'y ' limit just under [which]. Notice how once an item is selected instr(opt$,"@") checks for ' @ ' to insert the prefix ' mailto: ' so that Outlook Express etc is started. You will see the note allowing a Subject to be inserted, which could be done by inserting a PROMPT if you wish.

Gordon Sweet

The code below requires the LB1.txt file included in the zip archive of this issue.


'Alternative Email Address Book and Favorites list
'to block virus propagation. Use first Item to alter
'listing, Note two lines needed for each Address."
' RIGHT to access alternative TXT lists
' File LB1.txt needed

    nomainwin
    ux = 1 : uy = 1
    if DisplayWidth > 1000 then ux = 120 : uy = 90
    UpperLeftX = ux : UpperLeftY = uy
    File$ = "LB1.txt"  ' INITIAL ADDRESSES FILE
    dim name$(200, 200) : dim info$(1, 1)
[start]
    redim name$(200, 200) : redim info$(1, 1)
    gosub [load]
    height = int(count/5) * 30 + 40
    if int(count/5)<>count/5 then height = height + 30
    UpperLeftX = ux : UpperLeftY = ux
    WindowWidth = 800 : WindowHeight = height
    tl$ = "Fast Email & Favorites Address Book. Total ";str$(count)
    tl$ = tl$ +" - RIGHT CLICK FOR ALTERANTIVE ADDRESS FILE"
    open tl$ for graphics_nsb_nf as #a
    #a "trapclose [quit]; cls"
    #a "when leftButtonDown [which]; when rightButtonUp [nfile]"
    #a "cls; font fixedsys; backcolor darkblue; color yellow; down"
    y = 10 : C = 1 : endr = (count+4) / 5
    for row = 1 to endr : x = 4
    for colm = 1 to 5
        #a "place ";x;" ";y
        #a "boxfilled ";x+140;" ";y+20
        #a "place ";x+10;" ";y+14
        show$ = "\";name$(C,1) : C = C + 1
        if len(show$)>16 then show$=left$(show$,16)
        #a show$;
        x=x+160
    next colm
    y = y + 30 : next row
    #a "flush"
[hold]
    beep : wait

[which]
    x=MouseX : y=MouseY
    if x < 4 or x > 780 then [hold]
    if y < 10 or y > height then [hold]
    upper = 10 : lower = 28 : row = -1
    for dat = 1 to 19
        if y > upper and y < lower then row = dat -1
        upper = upper + 30 : lower = lower + 30
    next dat
    row = row * 5
    upper = 5 : lower = 142 : address = 0
    for dat = 1 to 5
        if x > upper and x < lower then address = dat
        upper = upper + 160 : lower = lower + 160
    next dat
    if dat = 0  or row < 0 or address = 0 then [hold]
    address = address + row : if address > count then [hold]
    if address = 1 then [amend]    ' *** AMENDMENTS ***
    opt$ = name$(address,2)
    if instr(opt$,"@") > 0 then
        opt$ = "mailto:" + opt$ ' mailto inserted
    end if
    CALL RunThis opt$ ,h
    goto [hold]

'FOR FULL DETAILS TO INCLUDE THE SUBJECT USE:-
'CALL RunThis "carlg@libertybasic.com?Subject=Liberty BASIC" ,h

[load]
    files DefaultDir$,File$ , info$(
    if val(info$(0, 0)) = 0 then
        notice "NO ";File$;" FILE!!"
        end
    end if
    open File$ for input as #dat
    count = 0: ok=0 : while ok=0
    if eof(#dat) < 0  then ok = 1 : goto [last]
    if count = 95 then
    notice "Restricted to 95 addresses!"
        ok = 1
        goto [last]
    end if
    count = count + 1
    line input #dat, n$
    name$(count, 1)=n$
    line input #dat, a$
    name$(count, 2)=a$
[last]
    wend : close #dat
    sort name$(), 1, count, 1 ' Sort then Save
    return

[amend]
    run$ = "notepad.exe "+File$
    run run$, restore
    ' Save Amendments Re-sorted
    OPEN File$ FOR OUTPUT AS #2
    FOR n = 1 TO count
        #2 name$(n,1)
        #2 name$(n,2)
    NEXT n : CLOSE #2
    notice "Any Changes will be sorted"
    close #a : goto [start]

[nfile]
    redim name$(200, 200) : redim info$(1, 1)
    filedialog "Select Address.TXT file","*.txt",File$
    close #a : goto [start]

[quit]
    close #a : end

sub RunThis RunFile$, hWindow
     RunFile$=RunFile$+chr$(0)
     lpOperation$ = "open" + chr$(0)
     lpParameters$ = "" + chr$(0)
     lpDirectory$ = "" + chr$(0)
     nShowCmd = _SW_SHOWNORMAL

     open "shell32" for dll as #shell
     calldll #shell, "ShellExecuteA", _
         hWindow as long, _          'parent window
         lpOperation$ as ptr, _      'open or print
         RunFile$ as ptr, _          'file name
         lpParameters$ as ptr, _     'null
         lpDirectory$ as ptr, _      'default directory
         nShowCmd as long, _        'show window flag
         result as long
     close #shell
     if result <= 32 then notice "Error, Address Failure!"
end sub


Home

Tip Corner: Using

Game Programming

Round Buttons

Rotating Objects

LBW: Book Marks

Slide Puzzle

Speech DLL

Addresses

Beginners Programming

Newsletter help

Index